
//引入api接口get方法
import { request } from "../utils/request.js";

export default {
  // 获取页面数据请求,传给后台
  get: ({ curPage, eachPage }) => request({
    // GET获取数据
    type: "GET",
    url: "/api/cinemas",
    data: { curPage, eachPage },
  }),

  //添加一个影院的请求
  add: cinemas =>
    request({
      type: "post",
      url: "/api/cinemas/add",
      data: cinemas
    }),
  // 排片、放映厅获取数据
  getData: () => request({
    type: "GET",
    url: "/api/cinemas/getdata",
  }),

  //获取一个影院数据的请求
  getOne: _id => request({
    type: "get",
    url: `/api/cinemas/getone/${_id}`,
  }),

  //修改数据的请求
  change:
    ({ name, phone, address, status, _id }) => request({
      type: "PATCH",
      url: `/api/cinemas/change`,
      data: { name, phone, address, status, _id }
    }),

  // 查询
  find: ({ status, address }) => request({
    type: "GET",
    url: `/api/cinemas/find`,
    data: { status, address },
  }),

  //删除影院数据的请求
  delete: _id => request({
    type: "DELETE",
    url: `/api/cinemas/delete/${_id}`,
  }),

  //删除对应图片的请求
  deleteImg: ({ _id, url }) => request({
    //DELETE 删除数据
    type: "DELETE",
    // 获取动态的路径
    url: `/resource/cinemas/${_id}/imgs/${encodeURIComponent(url)} `,
  }),

}